package dev.werillib.net

import io.reactivex.Observable
import retrofit2.Retrofit

/**
 * create by weril 2018/11/27
 */
class RequestHelperImpl : RequestHelper {
    override fun <T> getApiServer(clazz: Class<T>): T {
        val retrofit: Retrofit? = NetManager.getRetrofit()
        return retrofit?.create(clazz) ?: throw Exception("NetManager not init")
    }

    override fun <T> sendRequest(observable: Observable<T>, requestBack: RequestBack<T>) {
        observable.compose(RxSchedulers.compose())
            .subscribe(BaseObserver(requestBack))
    }
}